﻿<Window x:Class="BlackNBT.ClientTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:nbt="clr-namespace:Black.NBT;assembly=Black.NBT"
        Title="Black - NBT Client Test"
        Width="1024"
        Height="768"
        Closing="OnClosing"
        WindowStartupLocation="CenterScreen">

    <!--  Ressource de la page  -->

    <Window.Resources>

        <ContextMenu x:Key="MainContextMenu" Opened="OnContextMenuOpened">
            <MenuItem Header="_New">
                <MenuItem Click="OnContextNewClick" Header="TagByte" />
                <MenuItem Click="OnContextNewClick" Header="TagCompound" />
                <MenuItem Click="OnContextNewClick" Header="TagDouble" />
                <MenuItem Click="OnContextNewClick" Header="TagFloat" />
                <MenuItem Click="OnContextNewClick" Header="TagInt" />
                <MenuItem Click="OnContextNewClick" Header="TagList" />
                <MenuItem Click="OnContextNewClick" Header="TagLong" />
                <MenuItem Click="OnContextNewClick" Header="TagShort" />
                <MenuItem Click="OnContextNewClick" Header="TagString" />
            </MenuItem>
            <MenuItem Click="OnContextEditClick" Header="_Edit" />
            <MenuItem Click="OnContextDeleteClick" Header="_Delete" />
        </ContextMenu>

    </Window.Resources>

    <!--  Root de la page  -->

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!--  Menu Principal  -->

        <Menu Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem x:Name="MenuOpen"
                          Click="OnMenuOpenClick"
                          Header="_Open..." />
                <MenuItem x:Name="MenuClose"
                          Click="OnMenuCloseClick"
                          Header="_Close"
                          IsEnabled="False" />
                <Separator />
                <MenuItem x:Name="MenuSave"
                          Click="OnMenuSaveClick"
                          Header="_Save"
                          IsEnabled="False" />
                <MenuItem x:Name="MenuSaveAs"
                          Click="OnMenuSaveAsClick"
                          Header="_Save as..."
                          IsEnabled="False" />
                <Separator />
                <MenuItem x:Name="MenuExit"
                          Click="OnMenuExitClick"
                          Header="_Exit" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem x:Name="MenuAbout"
                          Click="OnMenuAboutClick"
                          Header="_About" />
            </MenuItem>
        </Menu>

        <!--  Vision du fichier  -->

        <TreeView x:Name="MainTreeView" Grid.Row="1">
            <TreeView.Resources>
                <HierarchicalDataTemplate DataType="{x:Type nbt:TagCompound}" ItemsSource="{Binding Path=Items}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Compound.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock VerticalAlignment="Center" Text=", Count:" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Count}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <HierarchicalDataTemplate DataType="{x:Type nbt:TagList}" ItemsSource="{Binding Path=Items}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/List.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock VerticalAlignment="Center" Text=", Count:" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Count}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagByte}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Byte.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagDouble}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Double.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagFloat}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Float.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagInt}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Int.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagLong}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Long.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagShort}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/Short.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagString}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/String.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="=" />
                        <TextBlock Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Value}" />
                    </StackPanel>
                </DataTemplate>
                <DataTemplate DataType="{x:Type nbt:TagByteArray}">
                    <StackPanel Margin="5"
                                ContextMenu="{StaticResource MainContextMenu}"
                                MouseDown="OnNodeMouseDown"
                                Orientation="Horizontal">
                        <Image VerticalAlignment="Center"
                               Source="/Assets/ByteArray.png"
                               Stretch="None" />
                        <TextBlock Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Path=Name}" />
                    </StackPanel>
                </DataTemplate>
            </TreeView.Resources>
        </TreeView>

    </Grid>

</Window>
